home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 6
/
The Arsenal Files 6 (Arsenal Computer).ISO
/
business
/
hap101.zip
/
HAP.DOC
< prev
next >
Wrap
Text File
|
1996-01-18
|
45KB
|
1,142 lines
!!!Check the file CATALOG.DOC for great prices on home automation products!!!
Precision Systems
HAP
Excellence in Home Automation
----------------------------------------------------------------------
Introduction
----------------------------------------------------------------------
If you think about it, almost all computer applications do a similar
thing: create display or printed output based on user input. You are
confined to the world as defined by the box sitting on your desk.
A home automation system is a whole different angle on the use of the
computer, in that your computer now interacts with you in YOUR world.
Imagine, sitting down for dinner, and pressing one button to set up the
house for a nice, romantic dinner. The lights come down to a nice mood
setting, the TV turns off, the stereo system plays a nice classical CD,
the phone ringers are disabled, the drapes slide closed, and the ceiling
fan turns on at 50% power, if it is warm inside. This is only scratching
the surface of the things that can be done when you use a computer to
automate the features in your home.
We invite you to explore this document and software, in hopes that you
will find it invaluable to you and your home!
----------------------------------------------------------------------
Disclaimer
----------------------------------------------------------------------
This software was released by Precision Systems 1/1/96. I encourage you
to copy and distribute this SHAREWARE VERSION of the software as you
wish, so long as it remains intact with this documentation and all other
supplied files in their unmodified form. PRECISION SYSTEMS WILL NOT BE
RESPONSIBLE FOR ANY LOSSES INCURRED FROM THE USE OF THIS SOFTWARE. USE
OF THIS SOFTWARE INDICATES ACCEPTANCE OF THESE TERMS.
Now that that's over with.......
----------------------------------------------------------------------
HAP History
----------------------------------------------------------------------
Recently, I was browsing through some on-line magazines, and encountered
an article regarding X-10 home automation products. I had heard of the
stuff before, and even tinkered with it, but never realized the full
potential that it has. I predict a proliferation of home automation
products in the near future. I have created this package as a start for
a more complete system, so expect it to be updated frequently. I will
put in a plug for the registered version here. It is not limited, and
comes with the TW-523 module and cables to get you started.
----------------------------------------------------------------------
How to get started with home automation
----------------------------------------------------------------------
It is possible to get started without much investment. I spent around
$100 to get remote control of the lights in my living room, including
full dimming capabilities for all lights. This included a two-button
keychain remote with receiver, and a large remote capable of controlling
16 modules. I spent about 2 hours hooking it all up. Check out the
file CATALOG.DOC for special package deals on startup kits.
A basic system consists of several different items, including wall
switches, remotes, plug in modules, etc. Transmitters talk to the
other units over the power lines, via quick pulses when the AC cycle
is near the 0 voltage position. Each switch or module has a house
code, and a unit code. There are 16 different house codes and 16
different unit codes, allowing for a maximum of 256 different codes.
Adding a computer to the equation only requires the addition of a
plug in module that also attaches to your computer. Software, like
this software, then becomes the link between your computer and your
house.
----------------------------------------------------------------------
X10 Components
----------------------------------------------------------------------
This section briefly describes some of the components that are available
for the X10 system. More are available, but the following units are the
most common. All of these items are available from us at mail-order
prices in the CATALOG.DOC supplied with this package.
Wall Switch -
This unit directly replaces your existing toggle switch that is built
into the wall. Units are available for 3-way wiring also. You get
the added benefit of dimming capability to the lights that are
connected to the switch. The dimming function is not available on the
standard wall switches, but they respond to the DIM and BRIGHT commands
sent from X10 transmitters. These units also respond to the ALL UNITS
OFF command, and the ALL LIGHTS ON command.
Lamp Module -
This unit plugs into the wall, and you plug a lamp into the unit.
It is similar to the wall switch in functionality, but there is no
button on it. However, if you want to turn the lamp on, the unit
will sense you turning it on and activate the module.
Appliance Module -
This unit is similar to the lamp module, but does not support the
dimming capabilities. This is good for TVs, radios, popcorn makers,
etc. These units respond to the ALL UNITS OFF command, but not the
ALL LIGHTS ON command.
PowerFlash Module -
This unit was originally designed as an interface to existing
home security systems, but functions nicely as a way to enable
non-X10 units to send X10 codes.
Universal Module -
This unit is the complement to the PowerFlash Module, in that it
receives X10 signals, and closes a relay circuit when it's code is
received. The Universal Modules also includes a chime, so is nice
in conjunction with motion sensors to let you know when someone is
approaching the house.
TW-523 Interface -
This is the unit that connects your computer to the X10 system. It
is bidirectional (sends and receives X10 signals) and is the
interface used in all bidirectional X10 home automation systems.
Many more nifty devices are available. They are covered in the catalog.
----------------------------------------------------------------------
Other Components
----------------------------------------------------------------------
This registed version of this program is capable of talking to your
infra-red controlled equipment. For instance, your VCR, stereo, TV,
etc. can be under control of your computer to provide the functionality
listed in the 'home automation uses' section of this documentation.
For this to happen, you will need to obtain the following components,
of course available in our supplied catalog CATALOG.DOC.
All for One remote -
A product designed as a remote control to control all of your
audio/video equipment, has all current equipment pre-programmed into
it. When new equipment comes along, it is reprogrammable via a
computer interface built into the remote. The nice thing about this,
is that the computer interface can be attached to a PC so that the PC
can 'press buttons' on the remote. An exceptional product.
I velcro'd my remote to the side of the PC, for a nice, integrated look.
All for One remote to PC interface cable -
This is the cable required to attach the remote to your PC. It connects
to a serial port.
Powermid remote extender -
This is needed if the PC is not in direct visual range of the equipment
you wish to control. It monitors for infra-red signals and transmits
them to a receiver unit via RF (radio), then converts them back to
infrared signals. Your PC can then talk to your audio-video equipment
from any room in the house. These are also nice for controlling your
equipment from the bedroom, etc. Multiple transmitters are allowed
to be in the system.
Sound Card -
These are useful to add speech to your system. I found that the most
effective use of these is to use the SHELL command to shell to DOS
and play a .WAV file. We are currently starting to create a library
of .WAV files that are useful for home automation. Check our BBS for
the latest stuff.
----------------------------------------------------------------------
Business Opportunity
----------------------------------------------------------------------
After getting this software running and automating my house just a
little bit, I have sold several systems to my friends just by 'showing
off' my system. It is easy to sell, because the pieces are inexpensive
and the effect and convenience is outstanding.
Home automation service and products are a natural to sell along with
home security systems, home theater, central vacuum, etc.
----------------------------------------------------------------------
Home Automation Uses
----------------------------------------------------------------------
As I am sure I am not the first to develop some of these ideas, I will
not try to take credit for them. Here are some of the things I am doing
with my home - some of them are actually implemented, some of them I
have not been able to afford to construct yet, but most are possible
with this software package combined with the appropriate hardware.
Mood setting is the most significant use of this software combined with
home automation hardware. Instead of having control over individual
lights or equipment, I have found that there are several standard
configurations that the house ends up in. Visualize some of the
following scenarios:
Button 1, VCR viewing mode
--------------------------
In my home, I can press button 1 on my remote to 'set up the house'
for watching a movie. All I have to do is insert the movie into the
VCR, sit down, and press button 1, which does the following:
1) Turn the TV on, turn the volume all the way down (I prefer to
pipe the sound through the stereo), and set it to channel 04.
2) Turn the stereo on, set it so that is is using the VCR as an
input, and set the volume to 30% (a nice starting volume).
Also turn on and setup any home theater equipment.
3) If it is summer, set the ceiling fan on 50% for a gentle breeze.
4) My house does not yet have automatic draperies, but the system
could close the drapes.
5) If it is dark outside, set the living room lights to 10%,
otherwise turn them off. Also dim or turn off any other lights
that may affect the viewing area. When setting the lights,
bring them down slowly for a high-tech effect.
Button 1 again, VCR break mode
------------------------------
This is a nice touch to impress your guests, never mind the convenience!
1) Stop the VCR
2) Set stereo to 15% volume, tune in the local classical music
station (always makes good intermission music)
3) Bring the living room lights up to about 50%.
4) Bring all lights on the way to the bathrooms (including the
bathrooms) up to 70%. I use 70% so that you don't blast your
guests eyes out.
5) Start the popcorn maker, and maybe even pour a glass of wine.
(Yes, this is possible)
Button 1 again, VCR resume mode
-------------------------------
I think you get the idea - set the house up like it was when the
VCR mode was first started, and start the VCR again.
Button 1 off, end VCR mode
--------------------------
1) Turn off the TV
2) Set the stereo to play a nice evening CD (but only if it is
actually evening)
3) Bring the lights up some, to 70%.
Button 2, Romantic Dinner mode
------------------------------
1) Turn off the TV if it is on.
2) Set the stereo to play either a selected radio station
or CD, at 30% volume
3) Start the fireplace (I don't have one, but my dad has a nifty
gas fireplace that you simply use a switch to turn on)
4) Set the lights over the dining room table to 20%
5) Pour a couple of glasses of wine
6) Disable the telephones
Button 3, Sleep mode
--------------------
1) Turn on the electric blanket (this could also happen
automatically at a pre-selected time)
2) Turn all units in the house off, except in the bedrooms
3) Make sure the garage door is closed
4) Arm the alarm system
5) Shell to DOS and play a WAV file that says 'Goodnight, Everybody'.
Button 4 off, Home unoccupied
-----------------------------
Install an in-wall transmitter near the front door to activate this
mode, and the home occupied mode.
The system could know when to expect you back based on your schedule,
and warm up the house for you by turning the wall heaters on. At
night, lights in the house can go on and off for security.
When you arrive home at dark, the outside porch light would be on to
welcome you home!
Button 4 on, Home occupied
--------------------------
When you come home, press the occupied button to set the lighting
according to time of day, turn on some nice background music, etc.
Event scheduling is another way to automate your household. A sequence
for weekday wake-up might be:
1) If it is a weekend or a holiday, skip this sequence.
2) At 6:00AM, turn the stereo on a mellow station at 30% volume, and
also shell to DOS and play a 'Good Morning' .WAV file.
3) If the motion sensor in the living room does not detect your
presence after a few minutes, change the radio station to
something more obnoxious- perhaps a liberal talk show. Increase
the volume to 50%.
4) Start the coffee pot.
5) Open the drapes in the house to brighten up the morning.
Have you ever spent an hour programming your VCR to record your three
favorite shows, only to have it erased the next day when the power
flashes for 30 seconds? HAP can be programmed to start the VCR also.
The programming is then on diskette or hard disk, safe from power
outages.
We are just scratching the surface here. The possibilities seem endless.
Let your imagination go!
More ideas:
- How about a large CD jukebox that can hold your entire CD collection.
Create a database of all CDs and songs. Then you can ask the system
to play random selections of - say - good exercise music. This can
be done on a small scale with the existing CD changers available.
- Install a motion sensor outside. Also install a camera outside, and
a P.I.P. (Picture In Picture) system on your TV. When someone walks
up, have the system activate a chime, turn on the TV if it is not on,
and connect the outside camera to the P.I.P. display on the TV so you
can see who is coming up.
- Automate your lawns irrigation system. X10 modules are available
that do this nicely. Available also are moisture sensors that will
tell the system when the lawn needs to be watered. This works nice
in my area, because we are only allowed to water on odd numbered
days, and never if the day is the 31st. With a normal irrigation
controller, I am having to change the programming every month.
- Create an intelligent system that is intuitive. For example, every
evening you like to come home and watch the news. The system could
learn this, and automatically set up the TV when the news comes on.
This type of idea could be taken a long ways, but might border on
annoying at times.
------------------------------------------------------------------------
System Requirements
------------------------------------------------------------------------
- MS-DOS computer. Yes, it needs to be dedicated. Fortunately, the
software should run nicely on that 4.77 mhz 8086 XT sitting in the
closet under your 1970s white polyester leisure suit. This makes it
cheaper than buying some of the home control units that are available,
and gives you an opportunity to take the suit to the dump. Hook up
that old amber monochrome monitor that glitches now and then, load
this software, and Voila! Instant home automation.
- BI-DIRECTIONAL parallel port for the TW-523 interface (listed next).
- X10 TW-523 bidirectional interface, to send and receive the X-10
commands.
- RS-232 serial port, if you want infrared control. You will also
need the one-for-all remote, and interface cable.
We chose not to write the first version in Windows, as the system
requirements are, of course, much more demanding (and expensive). If
there is sufficient demand, I will create a Windows version.
------------------------------------------------------------------------
Availability of Source Code
------------------------------------------------------------------------
I am undecided on this issue. What good would it do you if you
made a bunch of changes, then wanted to update to the latest version?
I am willing to negotiate the issue.
This software is programmed in Borland's excellent C++ compiler.
---------------------------------------------------------------------
Registration
---------------------------------------------------------------------
Registration of this software encourages its further development and
perfection. The registered version entitles you to the following:
-> Fully capable and up-to-date version sent to you, along with a
printed copy of the documentation.
-> Access to upgrades via a special account on our BBS.
-> Priority on bug (what bugs..) fixes and enhancement suggestions.
How much?
Registration for HAP is $99.95. Registration INCLUDES a TW-523
powerline interface, registered HAP-BASIC software, and cables
necessary for connection of your computers parallel port to the TW-523.
Check the enclosed CATALOG.DOC for further information!
---------------------------------------------------------------------
How to contact us
---------------------------------------------------------------------
The place you will most likely get a timely response is our support
BBS, 'Metropolis'.
Precision Systems
P.O. Box 7796
Bend, OR 97708
(541) 330-0728
BBS Metropolis! (541) 389-5404 <=14400
---------------------------------------------------------------------
Installation and Configuration
---------------------------------------------------------------------
No special procedures are necessary for installation, as long as the
TW-523 is installed. Simply copy the files that accompany this document
into a subdirectory. We recommend C:\HAP.
-----------------------------------------------------------------------
Getting Started
-----------------------------------------------------------------------
Consider purchasing a startup package. There are several versions,
ranging from a basic equipment list, to a full package for infrared
control. Of course, the supplied CATALOG.DOC will help you with this.
After obtaining and installing the TW-523 interface, and/or the IR
interface, try some of the supplied .HAP sample programs.
To start HAP-BASIC, simply start the program with the .HAP script as
a parameter:
HAP CONTROL.HAP
Optional parameters are /Ix, to change the serial port for the infra-red
controller, and /Tx, to change the parallel port for the TW-523 interface.
Defaults are COM1 for the infra-red controller, and LPT1 for the TW-523
interface. For example:
HAP TEST.HAP /I2 /T3
This will run the automation script called TEST.HAP, using com2 for the
IR interface, and lpt3 for the TW-523 interface.
We encourage you to upload your .HAP programs to our BBS to share with
others. The BBS number is (541) 389-5404.
-----------------------------------------------------------------------
Defining Modules
-----------------------------------------------------------------------
Modules are defined early in the program to simplify the organization of
your home automation system. After the modules are defined, they can
be called by name, instead of remembering their specific unit codes
or IR commands.
Currently, the only module type supported is 'X10'.
Example:
define module MBLIGHT type X10 { LampModule E16 }
The above example defines a module called MBLIGHT (Master Bedroom Light?)
that is an X10 lamp module addressed at housecode E, unit 16. Now you
can access that unit by referencing its name instead of memorizing
all of the X10 addresses. For example:
sendcmd MBLIGHT, "ON"
sendmcmd MBLIGHT, "DIM", 10
The supported X10 module types are:
- WallSwitch
- LampModule
- ApplianceModule
-----------------------------------------------------------------------
Defining Events
-----------------------------------------------------------------------
Events are an extension to the standard BASIC language, made specifically
for home automation purposes. They are used to define something that
can happen that you would like to process.
An event might be one of the following:
- A button pressed on an X10 controller
- A time of day
- Every minute
- Every hour
An event is defined by placing a 'Define Event' command at the beginning
of your HAP-BASIC program. After the 'Define Event', the name of the
event follows. The body of the event is thereafter defined.
Example:
define event VCRPLAY
{
X10Code A4 ON
}
The example above would generate an event called VCRPLAY when A4 ON
is received.
Example:
define event WAKEUP
{
Time 17:54-.MTWTF.
}
The example above would generate an event called WAKEUP at 5:54pm Monday,
Tuesday, Wednesday, Thursday, Friday, but not Saturday or Sunday.
Example:
define event MINUTE
{
Every Minute
}
The example above would generate an event called MINUTE every minute.
This is handy for doing screen updates in the HAP-BASIC program.
Example:
define event HOUR
{
Every Hour
}
The example above would generate an event called HOUR every hour.
The above examples outline all currently supported event types. They
are summarized here:
Every Minute - generates an event every minute
Every Hour - generates an event every hour
Time HH:MM-SMTWTFS - Generates an event at the specified time on the
specified days. If you do not want an event to
occur on a specific day, replace the letter with
a period '.'. Example: Time 10:15-S.T.T.S would
generate the event at 10:15 in the morning every
Sunday, Tuesday, Thursday, and Saturday.
X10Code Hnn mode - Generates an event when the specified X10 code
is received by the interface. Example:
X10Code E14 ON would generate an event when E14 ON
is received.
For more thorough examples, refer to the sample .HAP files supplied with
this package.
-------------------------------------------------------------------------
The HAP interpreter
-------------------------------------------------------------------------
We chose to use a free form interpreter instead of a 'point and click'
programming interface because it provides more flexibility, is not
difficult to learn, and creates a more robust automation system. For
instance, it is difficult to express to a 'point and click' interface
that you want to water your lawn only on odd numbered days, and never
on the 31st. A free-form programming language can easily accomplish
this task with simple modulo math.
Another factor for the decision to use a free form language is you.
If you are interested in home automation, you are probably the type of
person that has already spent time tinkering with computer programming.
When you were 10 years old, you wired a switch to your bed that turned
your TV on and off, maybe built your own stereo, fixed your mom's blender
(or took it apart to try), etc. I am that type of person, and enjoy
exploring technology. Odds are, you are the same.
The interpreter is based around the popular programming language 'BASIC'.
If you have prior experience programming in BASIC, great! All you need
to do is learn the extensions supplied that are specific to home
automation and you are on your way. If you don't have programming
experience, fear not. Sample programs are supplied and you will find
it easy to follow what is happening and modify it to your needs.
Things to know:
1) The interpreter is integer based, and does not support floating point
math.
2) The interpreter is not a complete set of BASIC commands, just those
that we thought appropriate to home automation, plus some extras.
3) If demand for this product exists, we will improve upon the
functionality of the interpreter. As it sits now, it should be able
to handle most needs for home automation.
4) The interface to the X10 TW-523 module is interrupt driven, and
therefore does not always require attention from your BASIC program.
The last 100 X10 commands are stored in a buffer and are available
at any time.
It is beyond the scope of this manual to provide instruction on
programming methods and theories, but all supported commands and their
syntax is covered, along with the extensions to the language.
Probably the easiest way to learn this is to start with the sample
program that is included in this package, COMPLEX.HAP. Modify it to
work with your house. After that, you should have no problem learning
the more advanced commands. Take your time, and add one thing at a time.
The following commands are supported in the HAP-BASIC interpreter:
PRINT
Print information to the screen at the current location, and in the
current colors.
Examples: PRINT "Hello there, ";name$;"!"
PRINT " Fourteen plus Three equals ";14+3
A semicolon at the end of the statement will keep the interpreter
from sending a linefeed/carraige return.
Example: PRINT "This is a ";
PRINT "test"
Will result in: This is a test
INPUT
Ask user for information.
Examples: INPUT "Enter your name", name$
REM
A remark, or comment. Everything on a line after an REM command is
ignored. Comments are useful for making your program more readable.
Example: REM This is a comment
IF / THEN
Conditional processing. IF a condition is true, THEN do something.
Example: IF X>10 THEN GOSUB Routine:
If the value of X is greater than 10, then execute the
subroutine called 'Routine'
Note: Typical BASIC AND and OR statements are not supported yet.
FOR / TO / NEXT
Process code several times.
Example: FOR X = 1 TO 20
{code to be repeated}
{many lines can be in between the FOR and NEXT commands}
PRINT X
NEXT
This example will print the numbers 1 thru 20.
Note: STEP as defined in typical BASIC is not supported yet.
GOTO
Branch execution to another location.
Example: GOTO Routine:
Execution of the program will be transferred to the code
beginning at the label 'Routine:'.
GOSUB / RETURN
Branch execution to a subroutine.
Example: PRINT "A Rose ";
GOSUB Routine:
PRINT "by any other name."
Routine:
PRINT "is a rose. . . ";
RETURN
End result of the above code fragment will result in:
A Rose is a rose. . . by any other name.
START
Specifies the start of the program. Be sure to place a START command
AFTER the modules and events have been defined.
END
Specifies the end of the program. When the interpreter encounters
the END command, the program finishes.
DIM
Specify the dimensions of a variable array.
Example: DIM A$(10)
If you have a need for arrays, you must use the DIM command to
tell the interpreter what the dimensions of the array are.
CLS
Clears the screen.
BEEP
Creates a system beep from the computers built in speaker.
COLOR ff,bb
Change the system colors. The first parameter is the foreground color,
the second is the background color.
Colors:
Black 0
Blue 1
Green 2
Cyan 3
Red 4
Magenta 5
Brown 6
White 7
Dark Gray 8
Light Blue 9
Light Green 10
Light Cyan 11
Light Red 12
Light Magenta 13
Yellow 14
Bright White 15
Note: Colors 8-15 when specified for background color
result in blinking text.
Example: COLOR 4,7
PRINT "This text is red on white"
LOCATE
Position the cursor at a specific location.
Example: LOCATE 10,20
This example will move the cursor to row 10, column 20.
The following commands are extensions to the BASIC language:
EVENT_CHECK
Tells the system to check for any events that may have occurred, and
flags them as active. Available events can be retrieved by using the
function 'EVENT_AVAIL(0)'. Use EVENT_CHECK before using
'EVENT_AVAIL(0)', or the computer will never test to see if the events
need to be triggered.
This command should be executed at least every minute, so that timed
events will be triggered. What this means is, don't design your event
processors so that they take more than a minute to execute, or you might
miss a timed event.
Example: EVENT_CHECK
event = EVENT_AVAIL(0)
EVENT_RESET n
Resets the triggered state of an event after you have processed it.
Specify the event that you are resetting.
If you don't reset an event, it will indefinitely be active.
Example: EVENT_CHECK
event = EVENT_AVAIL(0)
if event = WAKEUP then gosub Wakeup:
Wakeup:
EVENT_RESET event
(process event here)
return
SHELL
This command will shell an external program, command, or batch file.
Example: SHELL "DIR"
SHELL "HELLO.EXE"
SHELL "COMMAND.COM"
SHELL "COMMAND.COM" gives you a DOS prompt, allowing you to execute
DOS commands. To return to the program from a COMMAND.COM shell,
type EXIT and press Enter.
SLEEP n
Creates a delay of n seconds.
Example: SLEEP 10
X10SENDCMD "xx", "yy"
Send an X10 command. The first parameter is the housecode and unitcode
to send, the second parameter is the command.
Commands can be one of the following:
ON
OFF
Example: X10SENDCMD "E4", "ON"
Will turn on the X10 Module(s) with housecode "E" and unitcode
"4".
See Also: SENDCMD
X10SENDMCMD "x", "yy", nn
Send multiple X10 commands. The first parameter is the housecode and
unitcode, the second parameter is the command, and the third parameter
is the number of times to send the command.
Commands can be one of the following:
DIM
BRI
Example: X10SENDMCMD "J2", "DIM", 5
Will send 5 DIM commands to the X10 module(s) with the
housecode "J" and unitcode "2".
See Also: SENDMCMD
X10SENDUNIT "xx"
This command sends only a unit code. The first and only parameter is
the housecode/unitcode. This command is useful in conjunction
with the X10SENDFUNC and X10SENDMFUNC commands to control multiple
devices simultaneously.
Example: X10SENDUNIT "A12"
X10SENDUNIT "A13"
X10SENDFUNC "A", "ON"
X10SENDMFUNC "A", "DIM", 5
This example will send 5 DIMBRI commands to modules on
housecode A, units 12 and 13.
See Also: SENDUNIT
X10SENDFUNC "x", "yy"
This command sends function codes. The first parameter is the housecode
to use, the second is the command to send. Use this command in
conjunction with X10SENDUNIT to control multiple units simultaneously.
Commands can be one of the following:
ON
OFF
AUOFF - all units off
ALON - all lights on
ALOFF - all lights off
Example: See X10SENDUNIT example.
See Also: SENDFUNC
X10SENDMFUNC "x", "yy", z
This command sends multiple function codes. The first parameter is
the housecode, the second is the command, the third is the number of
times to send the command. Use this command in conjunction with
X10SENDUNIT to control multiple units simultaneously.
Commands can be one of the following:
DIM
BRI
Example: See X10SENDUNIT example.
See Also: SENDMFUNC
SENDCMD
SENDMCMD
SENDUNIT
SENDFUNC
SENDMFUNC
These commands are similar to the X10xxxxx commands listed above, but
accept the event names instead of housecode/unitcode strings. This
is handy for naming your devices, instead of having to remember their
X-10 addresses. It is much easier to remember "BEDROOMLIGHT" instead
of "J12".
Example: define module CEILINGFAN type X10 { LampModule E8 }
sendcmd CEILINGFAN, "ON"
IRSEND "xxxxxx" (Registered version only)
This command is for sending commands to your infra-red interface.
The commands you send relate directly to the buttons on the one-for-all
remote control attached to the serial port. The commands are put in
the string just as they are labeled on the remote, with the following
exceptions:
CHUP = Channel Up
CHDN = Channel Down
VOLUP = Volume Up
VOLDN = Volume Down
REW = Rewind ( < )
FREW = Fast Rewind ( << )
FFWD = Fast Forward ( >> )
Examples:
IRSend "AMP VOLUP VOLUP VOLUP"
IRSend "VCR PLAY"
The following functions are supported in HAP-BASIC:
ABS(x) - returns absolute value of x
ASC(x$) - returns ASCII code of first char in string x$
LEN(x$) - returns the length of x$ in bytes
POS(0) - returns current cursor column
VAL(x$) - returns the value of X$ (converts text to numeric)
CHR$(x) - returns character of ASCII value x
LEFT$(x$,n) - returns the left 'n' characters of x$
RIGHT$(x$,n) - returns the right 'n' characters of x$
MID$(x$,n[,m]) - returns portion of x$ starting at n for m bytes
LTRIM$(x$) - returns trimmed string (removes leading spaces)
RTRIM$(x$) - returns trimmed string (removes trailing spaces)
SPACE$(n) - returns a string consisting of 'n' spaces
TOLOWER$(x$) - returns string 'x$' but converted to lower case
TOUPPER$(x$) - returns string 'x$' but converted to upper case
The following functions are extensions to the BASIC language:
EVENT_AVAIL(0) -- Returns a handle to an event that needs processing.
The following Variables are processed specially by the interpreter.
Note that the variables can be read from or written to unless otherwise
specified.
CSRLIN -- Read only.. Returns the current line (row) that
the cursor is on
DATE$ -- Read only.. Returns system date in format MM-DD-YYYY
TIME$ -- Read only.. Returns system time in format HH:MM:SS
INKEY$ -- Returns keystroke, or NULL if no keystroke available
SYS_CASESENS -- Set this to true (1) for string variable compares to
be case sensitive, false (0) otherwise. Default is
true (1), as this is BASIC's normal mode.
SYS_VERSION$ -- Version number of the software, read only
------------------------------------------------------------------------
Programming tips
------------------------------------------------------------------------
The general structure of an automation program is a follows:
<define modules>
<define events>
<loop>
EVENT_CHECK
event = EVENT_AVAIL(0)
if event = xxxxx then gosub yyyyy
<end loop>
<event processor subroutines>
Many things can be added to the structure to provide screen output,
keyboard handling, etc. It all depends on what you need.
The following tips are items that we found helpful while programming
our automation system:
1) When developing an event processor, specify a key on the PC keyboard
that you can hit to simulate the event. For instance, if you are
developing a WAKEUP event that triggers at 6:00 each morning during
the week, it is not practical to make a change, then wait till 6:00
the next morning to see if it works. Either use the INKEY$ function
to watch for a keypress, or create a 'test event' that waits for an
X10 code, and dispatch those to your WAKEUP event processor.
2) Use the supplied example scripts as a basis for yours. They range
from easy to complicated.
3) Any suggestions you have to make this product more usable are
always considered and are helpful to the development of the product.
Our BBS is the best source for correspondence.
------------------------------------------------------------------------
X10 system caveats
------------------------------------------------------------------------
Darn. Now everything is working good, but some things just can't be
done. These are some of the issues that we came across, and how they
are dealt with.
- X10 is unable to start at specific brightness.
A true limitation of the X10 protocol. It is not possible to tell a
light to turn on at a specific brightness level. The light must be
brought on full, then brought down to the desired level. This is really
annoying during nice 'movie viewing' scripts. You press a button for
an intermission mode, and BLAM! the lights in the house come on and
fry you and your guest's eyes.
Solution:
Pick out the lights that you might want to come on later, and
dim them to zero. Then they can be brought up from zero, and not wake
everyone up so suddenly. It is not recommended to always turn lights
off this way, as the unit is still active and pulling power. This is
definitely not recommended for variable speed motor appliances (ceiling
fans).
- Light status synchronization.
Another limitation of the X10 protocol. There is no way to querry
a light to see if it is on or off. If the light is turned on from
the switch itself, the computer has no way of knowing that it's status
has changed. This is mostly a problem when you go to issue a DIM or
BRIGHT command, because if the light is off, and receives a DIM or
BRIGHT command, it first turns on at full brightness. Or, if the light
is totally dimmed to where it is not on, an ON command will not affect
it, since it's status is already ON.
Solution:
1) Use in-wall transmitters instead of normal switches. These units
send actual X10 Commands.
2) Use the handheld remotes to turn lights on and off.
3) Force the status to be known by first turning the light off before
issuing the ON command followed by DIM commands.
- One-way communications
Not only is there no way to know if a unit is on or off, there is no
way to know if a command you have issued has actually gotten to the unit
without verifying it physically.
- TV/Stereo/VCR power modes
Most audio/video equipment does not have specific on/off switches, but
rather a power switch that toggles the power. Therefore, when you
try to turn equipment on, and it is already on, you end up turning it
off. Sigh.
Solution:
Don't use the power buttons on your existing remotes. Use X10 commands
to control your equipment. It works nicer anyway, once it is set up.
- Signal suppression
Sometimes, good quality surge supression devices will block X10 signals
over the power lines. Bummer. If you are having problems with devices
not turning on or off, keep this fact in mind. Also try relocating the
X10 receiver as sometimes this helps.
------------------------------------------------------------------------
Planned Enhancements
------------------------------------------------------------------------
These are items that we will be adding, but didn't make this release.
Any suggestions are greatly appreciated for future versions.
These items are not a definitive list, and certainly not a complete
list, but represent changes we would like to make soon.
- Twilight calculator so the system knows the daylight level based on
latitude, longitude, day of year and current time.
- Further extensions to the HAP-BASIC language.
- Comprehensive error checking for the HAP-BASIC interpreter.
- Support for additional hardware, including A/D-D/A and relay boards.
------------------------------------------------------------------------
Important things to think about
------------------------------------------------------------------------
Home automation is fun, but keep the following points in mind:
Don't control things like curling irons, power tools, etc. When
designing your home automation system, remember that things can go wrong,
so don't put your home or lives in jeapordy by being careless.
ALWAYS CONSIDER WHAT WOULD HAPPEN IF SOMETHING DID NOT WORK RIGHT WHEN
DESIGNING YOUR AUTOMATION SYSTEM.
It is possible for other people to control your X10 devices, either via
power lines (you have an outside power receptacle, right?), or with the
remotes. Most of the remotes are on the same frequency. Also, a house
that is close to yours may receive your X10 codes through the power lines.
If this is a problem, arrange with your neighbors which housecodes to use.
Try not to configure your system so that you control his jacuzzi pump
with your lightswitch. Very annoying.
Don't control security sensitive things like garage doors, entry doors,
etc. with X10. There are ways to make it more secure, but we still don't
recommend it without a lot of thought. Think about the previous paragraph.
------------------------------------------------------------------------
Troubleshooting
------------------------------------------------------------------------
When things don't work, I usually find that a troubleshooting guide
answers all questions except the ones I have. This may be the case
here also, but look anyway, because the answer just might be here.
1) Lights are not going on when X10 codes are sent.
First, check the connection to the TW-523 interface. There is a
status LED on the interface that flashes when X10 codes are sent
OR received. If the LED is flashing but the lights are not
changing, you may need to link the two phases of your power together.
Try using standard X10 remotes and receivers in the same power outlet
to diagnose this further. If needed, an X10 signal bridge is
available to solve the problem.
Also, check your house for surge suppression. Sometimes, surge
supressors can block the X10 codes, as they look just like noise
on the power line.
More in the next release...but you are welcome to call our BBS with
questions if you need more help.